//
//  BaseVC.swift
//  feiyu444
//
//  Created by hanweiguang on 2018/10/10.
//  Copyright © 2018年 hanweiguang. All rights reserved.
//

import UIKit

class BaseVC:  UIViewController{
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor=UIColor.color(hexString: "#ffffff")
    }



    func hideNavigator() {
        self.navigationController?.setNavigationBarHidden(true, animated: true)
    }

    func showNavivagor() {
        self.navigationController?.setNavigationBarHidden(false, animated: true)
    }

    // 设置navigation的右边按钮
    func createCloseApp() {

        let   backB = UIButton.init(frame: CGRect.init(x: 0, y: 0, width: 20, height: 20))
        backB.setBackgroundImage(UIImage.init(named:"out_login_icon"), for: .normal)
        //backB.setImage(UIImage.init(named:"out_login_icon"), for: UIControl.State.normal)
        backB.addTarget(self, action: #selector(closeBtnPressed), for: UIControl.Event.touchUpInside)
        let backItem = UIBarButtonItem.init(customView: backB)
        self.navigationItem.rightBarButtonItem = backItem
    }
    @objc    func  closeBtnPressed(){

        let alert = DRSAlertDialog(title: "提示", message: "是否确认退出此账号", messageColor: UIColor.red)

        alert.addButton(ButtonType.button_OTHER, title: "取消") { (item) -> Void in
        }
        alert.addButton(ButtonType.button_OTHER, title: "确定") { (item) -> Void in
        }
        alert.show()
    }

    func createBtnBack() -> Void {
        let   backB = UIButton.init()
        backB.setImage(UIImage.init(named:"ic_back_arrow_black"), for: UIControl.State.normal)
        backB.addTarget(self, action: #selector(backBtnPressed), for: UIControl.Event.touchUpInside)
        let backItem = UIBarButtonItem.init(customView: backB)
        self.navigationItem.leftBarButtonItem = backItem

    }
    @objc    func  backBtnPressed(){
        self.navigationController!.popViewController(animated: true)

    }

}
